//
//  NetworkManger+User.m
//  DeepBreathing
//
//  Created by rimi on 15/12/16.
//  Copyright © 2015年 rimi. All rights reserved.
//

#import "NetworkManger+User.h"

#import "UserModel.h"

@implementation NetworkManger (User)
//APP用户登录~
+(void)loginWithUsername:(NSString *)username password:(NSString *)password successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    [self postWithUrl:@"app/user/login.html" params:@{@"phone":username,@"password":password,@"token":[UserModel defaultUser].token,@"type":@"iphone"} successHander:success failureHander:failure];
    
  
}

//APP用户注册~
+ (void)signUpWithUserName:(NSString *)username password:(NSString *)password rePwd:(NSString*)rePwd code:(NSString *)code successHandler:(SuccessHander) success failureHandler:(FailureHander)failure{
    
    [self postWithUrl:@"app/user/regist.html" params:@{@"name":username,@"password":password,@"code":code,@"rePwd":rePwd} successHander:success failureHander:failure];
    
    
    
}
//获取用户信息
+(void)getInfoWithsuccessHandler:(SuccessHander) success failureHandler:(FailureHander)failure{
    
    [self postWithUrl:@"app/user/getUserInfo.html" params:[NetworkManger parasByappendingUserInfo:nil] successHander:success failureHander:failure];
}
//验证手机号
+(void)verifPhoneNumberWithPhoneNumber:(NSString *)phone successHandler:(SuccessHander) success failureHandler:(FailureHander)failure{
    
    [self postWithUrl:@"app/user/checkPhone.html" params:@{@"name":phone} successHander:success failureHander:failure];
    
    
}
//修改用户资料
+(void)changeUserInfoWithname:(NSString *)name age:(int)age sickTime:(int)sickTime height:(int)height weight:(int)weight smoking:(int)smoking heredity:(int)heredity sex:(int)sex fev:(NSString *)fev pef:(NSString *)pef successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    [self postWithUrl:@"app/user/update.html" params:
  @{@"name":name,@"age":@(age),@"sickTime":@(sickTime),@"height":@(height),@"weight":@(weight),@"smoking":@(smoking),@"heredity":@(heredity),@"sex":@(sex),@"fev":fev,@"pef":pef}
        successHander:success failureHander:failure];
}
//忘记密码 检测验证码~
+(void)forgetCodeThenDetectionWithPhoneNumber:(NSString *)phone code:(NSString *)code successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    [self postWithUrl:@"app/user/findPwdBefore.html" params:@{@"name":phone,@"code":code} successHander:success failureHander:failure];
    
    
    
}
//忘记密码 操作~
+(void)getCodeWhenGetSecurityCodeWithnewPwd:(NSString *)newpwd reNewPwd:(NSString *)renewpwd phoneNumber:(NSString *)phone successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    [self postWithUrl:@"app/user/findPwd.html" params:@{@"newPwd":newpwd,@"reNewPwd":renewpwd,@"name":phone} successHander:success failureHander:failure];
    
    
    
    
}
//修改密码(需原密码)
+(void)changeCodeWitholdPwd:(NSString *)oldPwd newPwd:(NSString *)newPwd reNewPwd:(NSString *)reNewPwd successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    
    [self postWithUrl:@"app/user/updatePwd.html" params:@{@"oldPwd":oldPwd,@"newPwd":newPwd,@"reNewPwd":reNewPwd} successHander:success failureHander:failure];
}
//更换手机号
+(void)changgePhoneNumberWithPhoneNumber:(NSString *)phone code:(NSString *)code successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    [self postWithUrl:@"app/user/updatePhone.html" params:@{@"phone":phone,@"code":code} successHander:success failureHander:failure];
    
    
}
//获取短信验证码~

+ (void)getCodeWhen:(NSString*)type withPhone:(NSString*)phone successHandler:(SuccessHander)success failureHandler:(FailureHander)failure
{
    [self postWithUrl:@"app/user/sendSms.html" params:@{@"name":phone,@"type":type} successHander:success failureHander:failure];
 
}
+(void)getDetectionNumberWhenRegisingWithPhoneNumber:(NSString *)phone successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    [self getCodeWhen:@"regist" withPhone:phone successHandler:success failureHandler:failure];
}

+(void)getDetectionNumberWhenGetingLostCodeWithPhoneNumber:(NSString *)phone successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    [self getCodeWhen:@"pwd" withPhone:phone successHandler:success failureHandler:failure];
}

+(void)getDetectionNumberWhenChangePhoneNumberWithPhoneNumber:(NSString *)phone successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    [self getCodeWhen:@"phone" withPhone:phone successHandler:success failureHandler:failure];
}









@end
